<template>
  <view class="counter-container">
    <section class="title">
      {{ counter.count }}
    </section>

    <nut-button
      type="primary"
      @click="onAdd"
    >
      Add
    </nut-button>
  </view>
</template>

<script>
import { useCounterStore } from '@/stores/counter';

export default {
  setup() {
    const counter = useCounterStore();

    const onAdd = () => {
      counter.count++;

      // with autocompletion ✨
      // counter.$patch({count: counter.count + 1})

      // or using an action instead
      // counter.increment()
    };

    return {
      counter,
      onAdd
    };
  }
};
</script>

<style lang="scss">
.counter-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
</style>
